package com.example.forjava.model.builder;

public class BuildModel  {

    private String name;
    private int age;
    private String mode;

    public static BuildModelBuilder builder(){
        return new BuildModelBuilder();
    }


    public static final class BuildModelBuilder {
        private String name;
        private int age;
        private String mode;

        private BuildModelBuilder() {
        }

        public static BuildModelBuilder aBuildModel() {
            return new BuildModelBuilder();
        }

        public BuildModelBuilder name(String name) {
            this.name = name;
            return this;
        }

        public BuildModelBuilder age(int age) {
            this.age = age;
            return this;
        }

        public BuildModelBuilder mode(String mode) {
            this.mode = mode;
            return this;
        }

        public BuildModel build() {
            BuildModel buildModel = new BuildModel();
            buildModel.age = this.age;
            buildModel.name = this.name;
            buildModel.mode = this.mode;
            return buildModel;
        }
    }

    @Override
    public String toString() {
        return "BuildModel{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", mode='" + mode + '\'' +
                '}';
    }

    public static void main(String[] args) {
        BuildModel build = BuildModel.builder().mode("build").name("tom").age(100).build();
        System.out.println(build);
    }
}
